/* Copyright (C) 2010 Fredrique Samuels, fredriquesamuels@gmail.com */

/*
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef TRI_MOUSE_EVENT_H_
#define TRI_MOUSE_EVENT_H_

#include <iostream>
#include <vector> 
#include "base/utils.h"


namespace tri {


/**
 * NULL enum
 */
enum {
	NONE = -1
};

/**
 * Event Enums
 */
enum event {
	BUTTON_RELEASED = 1000,
	BUTTON_PRESSED,
	BUTTON_CLICKED,
	MOUSE_DRAG,
	MOUSE_MOVE, //1005
	CLICKED,
	PRESSED,
	RELEASED,
	FOCUS,
	FOCUS_LOST,
	FOCUS_RECEIVED,
	MOUSE_OVER,  // 1010
	MOUSE_EXIT,
	MOUSE_ENTER,
	KEY_PRESSED,
	KEY_RELEASED,
	DISABLED,  // 1015
	CHECKED,
	VALUE_CHANGED,
	UPDATED

};

/**
 * Mouse Button Enums
 */
enum button {
	BUTTON_LEFT = 0,
	BUTTON_MIDDLE,
	BUTTON_RIGHT
};


class TDisplayEngine;
class TEventsProcess;
/**
 * Mouse Event structure
 */
class TMouseEvent {
	
	friend class TDisplayEngine;
	friend class TEventsProcess;
	
public:

	/**
	 * @param _x: mouse position X
	 * @param _y: mouse position Y
	 * @param _x_rel: mouse movement X(in case of 
	 * 			drag or pasive movemets of the mouse)
	 * @param _y_rel: mouse movement Y(in case of 
	 * 			drag or pasive movemets of the mouse)
	 * @param button: Active Button (used when 
	 * 				button is pressed or released).
	 * 				Defaults to NONE
	 * @param event:  event type enum
	 */
	TMouseEvent(int _x=-1, int _y=-1, int _x_rel=0, int _y_rel=0,
			int button = NONE, int event = NONE);
	virtual ~TMouseEvent();
	
	void set(int _x=-1, int _y=-1, int _x_rel=0, int _y_rel=0,
			int button = NONE, int event = NONE);
	
	void getIDList(std::vector<unsigned int>& list);
	
	int getX() const;
	int getY() const;
	int getRelativeX() const;
	int getRelativeY() const;
	int getButton() const;
	int getEvent() const;

	/**
	 * Copy a mouse_event instance.
	 * 
	 * @param src: Source event
	 * @param dst: Destination event
	 */
	static void copy(const TMouseEvent& src, TMouseEvent& dst);

	static TMouseEvent getCurrentEvent();
	static TMouseEvent getLastEvent();
	
	std::string toString() const;
	//std::ostream &operator<<(std::ostream&, const tri::TMouseEvent&);

private:
	int x;
	int y;
	int x_rel;
	int y_rel;
	int button;
	int event;
	//tri::entity* source;
	std::vector<unsigned int> IDList;

	static TMouseEvent s_CurrentEvent;
	static TMouseEvent s_LastEvent;

};

}



#endif /*EVENTS_H_*/
